/**
 * @author Ahammer
 * @date 2009 03
 */

/*
 * This file is part of Iqm.
 * Copyright (c) 2010-2011 Helmut Ahammer
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package op;

import java.awt.Dimension;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.image.SampleModel;
import java.awt.image.renderable.ParameterBlock;
import java.util.Arrays;

import javax.media.jai.BorderExtender;
import javax.media.jai.ImageLayout;
import javax.media.jai.Interpolation;
import javax.media.jai.JAI;
import javax.media.jai.KernelJAI;
import javax.media.jai.ParameterBlockJAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.TileCache;
import javax.media.jai.operator.AddDescriptor;
import javax.media.jai.operator.ConstantDescriptor;

import main.IqmTools;

/**
 * This is the main image processing class
 * There exist two approaches:
 * A user defined JAI operator is just called 
 * or:
 * The actual processing is implemented in this class 
 */
public class IqmInvertOperator{ 


  public IqmInvertOperator() {
	  //WARNING: Don't declare fields here
	  //Fields declared here aren't thread safe!   
  }
  /**
   * 
   * @param ParametrBlockJAI pb
   */
  public Object run(ParameterBlockJAI pbJAI){
	  RenderingHints rh = IqmTools.getDefaultTileCacheRenderingHints();

//	  PlanarImage pi = (PlanarImage) pbJAI.getSource(0);
//	  int width = pi.getWidth();
//	  int height = pi.getHeight();
//	  
//	  ImageLayout layout = new ImageLayout();
//	  layout.setTileWidth(width);
//	  layout.setTileHeight(height);
//
//	  RenderingHints rh = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
//	  ParameterBlock pb = new ParameterBlock();
//	  pb.addSource(pi);
//	  pi = JAI.create("Format", pb, rh);
//	  
//	  pbJAI.removeSources();
//	  pbJAI.addSource(pi);
	  
	  Object ob = JAI.create("IqmInvert".toLowerCase(), pbJAI, null);
	  
	  return ob;
  }
}
